﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace _02_创建泛型类
{
    class Array_List
    {
        public Array_ListNode First { get; set; }
        public Array_ListNode Last { get; set; }
     
        private Array_ListNode pro;
        public void Add(object node)
        {
            pro = new Array_ListNode(node);
            if (First==null)
            {
                this.First = pro;
                this.Last = pro;
             
                this.First.Prev = First;
                this.First.Next = First;
            }
            else
            {
                pro.Prev = this.Last;
               
                this.Last.Next = pro;
                this.Last = pro;
            }
        }

        public IEnumerator GetEnumerator()
        {
            Array_ListNode proNode=this.First;
            while (proNode != null)
            {
                yield return proNode.Values;
                proNode = proNode.Next;
            }
        }
    }
    class Array_ListNode
    {
        private object values;
        public object Values
        {
            get { return this.values; }
        }
        public Array_ListNode Prev { get; set; }
        public Array_ListNode Next { get; set; }
        public Array_ListNode(object o)
        {
            this.values = o;
        }
    }
}
